R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.3.3
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.3.3
## Warning: package 'tidyr' was built under R version 4.3.3
## Warning: package 'readr' was built under R version 4.3.3
## Warning: package 'purrr' was built under R version 4.3.3
## Warning: package 'dplyr' was built under R version 4.3.3
## Warning: package 'stringr' was built under R version 4.3.3
## Warning: package 'forcats' was built under R version 4.3.3
## Warning: package 'lubridate' was built under R version 4.3.3
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ lubridate 1.9.3     ✔ tibble    3.2.1
## ✔ purrr     1.0.2     ✔ tidyr     1.3.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(readxl)
library(dplyr)
library(plotly)
## Warning: package 'plotly' was built under R version 4.3.3
## 
## Attaching package: 'plotly'
## 
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## 
## The following object is masked from 'package:stats':
## 
##     filter
## 
## The following object is masked from 'package:graphics':
## 
##     layout
data_col<-read_excel("C:/Users/jangr/Downloads/Customers.xlsx")
View(data_col)

Including Plots

You can also embed plots, for example:

gender_val<- data_col %>% group_by(Gender) %>% summarise(total=n())
# pie- chart
pie_chart<- plot_ly(gender_val,labels= ~Gender , values = ~total,type="pie", textinfo="percent+label", hoverinfo="label+value") %>% layout(title=" Gender analysis")
pie_chart
#bar_chart
total_sales<- data_col %>% group_by(Gender) %>% summarise(total_sales=mean(Monthly_Expenses))
ggplot(total_sales,aes(x=Gender, y=total_sales,fill=Gender))+geom_bar(stat="identity")+
  labs(title="Average Income by Gender", x= "Gender", y="Average Income")+theme_minimal()

ggplot(data_col,aes(x=Age,y=Monthly_Expenses))+geom_point()+
  labs(title="Expenses",x="Age",y="Monthly Expenses")+
  theme_minimal()

mall_val<- data_col %>% group_by(favourite_Mall) %>% summarise(total=n())
# pie- chart
pie_chart<- plot_ly(mall_val,labels= ~favourite_Mall , values = ~total,type="pie", textinfo="percent+label", hoverinfo="label+value") %>% layout(title="Favourite Malls")
pie_chart
ggplot(data_col,aes(x= Gender,y= Spending_Score))+
  geom_boxplot()+
  labs(title = "Spending Score by Gender",x="Gender",y="Spending Score")+
  theme_minimal()

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.